package edu.kit.csl.pisa.models;

/*
This file is part of the PISA Alignment Tool.

Copyright (C) 2013
Karlsruhe Institute of Technology
Cognitive Systems Lab (CSL)
Felix Stahlberg

PISA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PISA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PISA. If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * These models are used by Model 4P to penalize mismatches between the number
 * of words in the source and target sentence. Which subclass to use depends on
 * the model4SentenceLengthModel parameter (GoF strategy pattern). 
 */
public interface SentenceLengthModel {

	/**
	 * Get the log probability P(nTrgtWords|nSrcWords).
	 *  
	 * @param nSrcWords number of source words
	 * @param nTrgtWords number of target words
	 * @return log prob P(nTrgtWords|nSrcWords)
	 */
	double getProbability(int nSrcWords, int nTrgtWords);
	
	/**
	 * Used to collect fractional counts. Count the occurrence of
	 * nTrgtWords|nSrcWords weighted with weight.
	 *  
	 * @param weight the weight (usually appr. log P(e|f))
	 * @param nSrcWords number of source words
	 * @param nTrgtWords number of target words
	 */
	void count(double weight, int nSrcWords, int nTrgtWords);
	
	/**
	 * Normalize collected counts.
	 * 
	 * @see #count(double,int,int)
	 */
	void normalize();
	
	/**
	 * Dump internal parameters to the file system.
	 * 
	 * @param prefix prefix of the dump file to create
	 * @param postfix postfix of the dump file to create
	 */
	public void dumpToFilesystem(String prefix, String postfix);
}
